package com.cxm.helper.service.impl;

import com.cxm.helper.util.constant.RabbitMqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: chenximeng
 * @date: 2022/12/2 17:45
 */
@Slf4j
@Component
public class RabbitMqService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    public void saveMsg(String message){
        log.info("mq send message：{}", message);
        rabbitTemplate.convertAndSend(RabbitMqConstant.MESSAGE_EXCHANGE, RabbitMqConstant.MESSAGE_SAVE_QUEUE, message);
    }

    public void readMsg(String message){
        log.info("mq read message：{}", message);
        rabbitTemplate.convertAndSend(RabbitMqConstant.MESSAGE_EXCHANGE, RabbitMqConstant.MESSAGE_READ_QUEUE, message);

    }
}
